﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data;
using MySql.Data.MySqlClient;

namespace BankOrder
{
    class ClientSql
    {
        private string url = "server=127.0.0.1;port=3306;user=root;password=123456;database=bank;Charset=utf8;SslMode=None;";
        private string sql = "";
        //private MySqlConnection mySqlConnection = new MySqlConnection(url);
        private MySqlDataReader reader = null;

        public int queryAllNum()
        {
            int nums = 0 ;
            url = "select count(*) from client;";
            MySqlConnection mySqlConnection = new MySqlConnection(url);
            try
            {
                mySqlConnection.Open();
                MySqlCommand mySqlCommand = new MySqlCommand(sql, mySqlConnection);
                reader = mySqlCommand.ExecuteReader();
                if (reader.Read())
                {
                    nums = reader.GetInt32(0);
                }
                mySqlConnection.Close();
            }
            catch
            {
                mySqlConnection.Close();
            }
            finally
            {
                mySqlConnection.Close();
            }
            return nums;
        }

        public bool intoQueue(int num,int time,int mode)
        {
            bool sign = false;
            // mode=1，VIP
            // mode=2，存款
            // mode=3，取款
            if (mode == 1)
            {
                sql=string.Format("insert into staff values('{},)")
            }
            if (mode == 2)
            {

            }
            if (mode == 3)
            {

            }
            return sign;
        }
    }
}
